<?php
/**
 * (commands) Amazon订单（补单）
 */
namespace App\Console\Commands\SpApi\Order;

use App\Logic\Amazon\Api\OrderWork;
use App\Models\Basics\AmazonAccount;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class GetOrdersByAccountIdTest extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sp-order:get-orders-account-test {accountId} {orderId*}';

    /**
     * The console command description.
     * @var string
     */
    protected $description = 'exe func';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     */
    public function handle(): void
    {
        $accountId = $this->argument('accountId');
        //单api账号（指定账号）
        $account = AmazonAccount::getModel($accountId);
        if (!$account) {
            $this->error('account error!');
        }
        $orderId = $this->argument('orderId');

        try {
            OrderWork::testAPIViaOrderID($account, $orderId);
        } catch (\Exception $e) {
        }
        Log::info('order-id:'.date('Y-m-d H:i:s',time()));
        $this->info('finish!');
    }
}
